package com.lc202407;

import java.util.ArrayList;

public class Solution500 {
    public String[] findWords(String[] words) {
        String[] keys = {"qwertyuiop", "asdfghjkl", "zxcvbnm"};
        ArrayList<String> res = new ArrayList<>();
        for (String word : words) {
            for (String key : keys) {
                int length = word.length();
                for (int i = 0; i < length; i++) {
                    if (!key.contains(word.substring(i, i + 1).toLowerCase())) {
                        break;
                    }
                    if (i == length - 1) {
                        res.add(word);
                        break;
                    }
                }
            }
        }
        return res.toArray(new String[0]);
    }
}
